import EventBus from '@renderer/util/event/EventBus'
import { Events } from '../event/Events'
import CacheUtil from '../CacheUtil'
import { Constants } from '../Constants'
export default class ThemeUtil {
  static switchDark() {
    EventBus.emit(Events.SWITCH_THEME, 'dark')
    CacheUtil.set(Constants.THEME, 'dark')
  }

  static switchLight() {
    EventBus.emit(Events.SWITCH_THEME, 'light')
    CacheUtil.set(Constants.THEME, 'light')
  }

  static switchTheme() {
    if (CacheUtil.get<string>(Constants.THEME)) {
      let theme = CacheUtil.get<string>(Constants.THEME)
      if (theme == 'dark') {
        ThemeUtil.switchLight()
      } else {
        ThemeUtil.switchDark()
      }
    } else {
      ThemeUtil.switchDark()
    }
  }
}
